<script>
import Vue from 'vue';
import request from '@/utils/request';
import { getToken } from '@/utils/auth'; // get token from cookie
import route from '@/utils/route';
export default {
	onLaunch: function() {
		Vue.prototype.$request = request;
		Vue.prototype.$route = route;
		uni.getSystemInfo({
			success: function(e) {
				// #ifndef MP
				Vue.prototype.StatusBar = e.statusBarHeight;
				if (e.platform == 'android') {
					Vue.prototype.CustomBar = e.statusBarHeight + 50;
				} else {
					Vue.prototype.CustomBar = e.statusBarHeight + 45;
				}
				// #endif
				// #ifdef MP-WEIXIN
				Vue.prototype.StatusBar = e.statusBarHeight;
				let custom = wx.getMenuButtonBoundingClientRect();
				Vue.prototype.Custom = custom;
				Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
				// #endif
				// #ifdef MP-ALIPAY
				Vue.prototype.StatusBar = e.statusBarHeight;
				Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
				// #endif
			}
		});
		// determine whether the user has logged in
		const hasToken = getToken();

		if (hasToken) {
			const hasGetUserInfo = this.$store.state.userInfo;
			console.log('hasGetUserInfo', hasGetUserInfo);
			if (hasGetUserInfo && hasGetUserInfo.token) {
			} else {
				this.$store
					.dispatch('getInfo')
					.then(() => {})
					.catch(() => {});
			}
		}
	},
	onShow: function() {
		console.log('App Show');
	},
	onHide: function() {
		console.log('App Hide');
	}
};
</script>

<style>
@import 'colorui/main.css';
@import 'colorui/icon.css';
</style>
